package com.kerwin.event;

import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;

public class Test {

    private static Queue<Task> queue = new LinkedBlockingQueue();

    private static void process(){
        Task task = null;
        while((task = queue.poll()) != null){
            task.run();
        }
    }

    ///开发角度的同步
    public static void main(String[] args) {
        System.out.println("begin");
        queue.add( new Task(){
            @Override
            public void run() {
                System.out.println("task1.....");

                queue.add( new Task(){
                    @Override
                    public void run() {
                        System.out.println("task3.....");
                    }
                });

            }
        });

        queue.add( new Task(){
            @Override
            public void run() {
                System.out.println("task2.....");
            }
        });

        System.out.println("end");



        process();

    }


}
